package com.learn.controller;

import com.learn.pojo.Result;
import com.learn.pojo.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ResponseController {

//    @RequestMapping("/hello")
//    public String hello(){
//        return "hello world";
//    }
//
//    @RequestMapping("/user")
//
//    public User user(){
//        User user = new User();
//        user.setName("张三");
//        user.setAge(18);
//        return user;
//    }
//
//    @RequestMapping("/users")
//    public List<User> users(){
//        User user1 = new User();
//        user1.setName("张三");
//        user1.setAge(18);
//        User user2 = new User();
//        user2.setName("张三");
//        user2.setAge(18);
//
//        return List.of(user1,user2);
//    }

    @RequestMapping("/hello")
    public Result hello(){
//        Result result = new Result("200","成功","hello world");
//        return result;
        return Result.success("hello world");
    }

    @RequestMapping("/user")

    public Result user(){
        User user = new User();
        user.setName("张三");
        user.setAge(18);
        return Result.success( user);
    }

    @RequestMapping("/users")
    public Result users(){
        User user1 = new User();
        user1.setName("张三");
        user1.setAge(18);
        User user2 = new User();
        user2.setName("张三");
        user2.setAge(18);

        return Result.success(List.of(user1,user2));
    }
}
